/*
 * Jenny Ruppen 09-730-391
 * Sebastien Goldberg 08-914-855
 * Henry Raymond 08-928-061
 * Stefan Mussato 09-752-270
 */
 
package ch.uzh.ifi.sopra.gruppe9.game;

import java.util.ArrayList;

/**
 * Class for tower elements. Each tower element has a unique ID. This class is used 
 * by the server and the client. RMI methods on the other hand only use the unique IDs without 
 * transmitting the TowerElement objects.  Each tower element has a type and a material. Use the
 * getElementPileForShop() method to create the tower element pile for a specific shop.
 */
public class TowerElement {
	
	public enum Type {BASE, MIDDLE, WINDOW, ROOF};
	public enum Material {BROWN, GREEN, RED, BLACK, WHITE};
	
	
	/**
	 * Unique ID of tower element
	 */
	private int id;
	
	private Type type;
	
	private Material material;
	
	private boolean golden;
	
	
	public TowerElement(int id) {
		this.id = id;
		
		switch(id) {
		
			// Base elements
			case 0: 	type = Type.BASE;		material = Material.BROWN;		golden = false; 	break;
			case 1: 	type = Type.BASE;		material = Material.BROWN;		golden = false; 	break;
			case 2: 	type = Type.BASE;		material = Material.BROWN;		golden = false; 	break;
			case 3: 	type = Type.BASE;		material = Material.BROWN;		golden = true; 		break;
			
			case 4: 	type = Type.BASE;		material = Material.GREEN;		golden = false; 	break;
			case 5: 	type = Type.BASE;		material = Material.GREEN;		golden = false; 	break;
			case 6: 	type = Type.BASE;		material = Material.GREEN;		golden = false; 	break;
			case 7: 	type = Type.BASE;		material = Material.GREEN;		golden = true; 		break;
			
			case 8: 	type = Type.BASE;		material = Material.RED;		golden = false; 	break;
			case 9: 	type = Type.BASE;		material = Material.RED;		golden = false; 	break;
			case 10: 	type = Type.BASE;		material = Material.RED;		golden = false; 	break;
			case 11: 	type = Type.BASE;		material = Material.RED;		golden = true; 		break;
			
			case 12: 	type = Type.BASE;		material = Material.BLACK;		golden = false; 	break;
			case 13: 	type = Type.BASE;		material = Material.BLACK;		golden = false; 	break;
			case 14: 	type = Type.BASE;		material = Material.BLACK;		golden = false; 	break;
			case 15: 	type = Type.BASE;		material = Material.BLACK;		golden = true; 		break;
			
			case 16: 	type = Type.BASE;		material = Material.WHITE;		golden = false; 	break;
			case 17: 	type = Type.BASE;		material = Material.WHITE;		golden = false; 	break;
			case 18: 	type = Type.BASE;		material = Material.WHITE;		golden = false; 	break;
			case 19: 	type = Type.BASE;		material = Material.WHITE;		golden = true; 		break;
			
			
			
			// Middle elements
			case 20: 	type = Type.MIDDLE;		material = Material.BROWN;		golden = false; 	break;
			case 21: 	type = Type.MIDDLE;		material = Material.BROWN;		golden = false; 	break;
			case 22: 	type = Type.MIDDLE;		material = Material.BROWN;		golden = false; 	break;
			case 23: 	type = Type.MIDDLE;		material = Material.BROWN;		golden = true; 		break;
			
			case 24: 	type = Type.MIDDLE;		material = Material.GREEN;		golden = false; 	break;
			case 25: 	type = Type.MIDDLE;		material = Material.GREEN;		golden = false; 	break;
			case 26: 	type = Type.MIDDLE;		material = Material.GREEN;		golden = false; 	break;
			case 27: 	type = Type.MIDDLE;		material = Material.GREEN;		golden = true; 		break;
			
			case 28: 	type = Type.MIDDLE;		material = Material.RED;		golden = false; 	break;
			case 29: 	type = Type.MIDDLE;		material = Material.RED;		golden = false; 	break;
			case 30: 	type = Type.MIDDLE;		material = Material.RED;		golden = false; 	break;
			case 31: 	type = Type.MIDDLE;		material = Material.RED;		golden = true; 		break;
			
			case 32: 	type = Type.MIDDLE;		material = Material.BLACK;		golden = false; 	break;
			case 33: 	type = Type.MIDDLE;		material = Material.BLACK;		golden = false; 	break;
			case 34: 	type = Type.MIDDLE;		material = Material.BLACK;		golden = false; 	break;
			case 35: 	type = Type.MIDDLE;		material = Material.BLACK;		golden = true; 		break;
			
			case 36: 	type = Type.MIDDLE;		material = Material.WHITE;		golden = false; 	break;
			case 37: 	type = Type.MIDDLE;		material = Material.WHITE;		golden = false; 	break;
			case 38: 	type = Type.MIDDLE;		material = Material.WHITE;		golden = false; 	break;
			case 39: 	type = Type.MIDDLE;		material = Material.WHITE;		golden = true; 		break;
			
			
			
			// Window elements
			case 40: 	type = Type.WINDOW;		material = Material.BROWN;		golden = false; 	break;
			case 41: 	type = Type.WINDOW;		material = Material.BROWN;		golden = false; 	break;
			case 42: 	type = Type.WINDOW;		material = Material.BROWN;		golden = false; 	break;
			case 43: 	type = Type.WINDOW;		material = Material.BROWN;		golden = false; 	break;
			case 44: 	type = Type.WINDOW;		material = Material.BROWN;		golden = true; 		break;
			
			case 45: 	type = Type.WINDOW;		material = Material.GREEN;		golden = false; 	break;
			case 46: 	type = Type.WINDOW;		material = Material.GREEN;		golden = false; 	break;
			case 47: 	type = Type.WINDOW;		material = Material.GREEN;		golden = false; 	break;
			case 48: 	type = Type.WINDOW;		material = Material.GREEN;		golden = false; 	break;
			case 49: 	type = Type.WINDOW;		material = Material.GREEN;		golden = true; 		break;
			
			case 50: 	type = Type.WINDOW;		material = Material.RED;		golden = false; 	break;
			case 51: 	type = Type.WINDOW;		material = Material.RED;		golden = false; 	break;
			case 52: 	type = Type.WINDOW;		material = Material.RED;		golden = false; 	break;
			case 53: 	type = Type.WINDOW;		material = Material.RED;		golden = false; 	break;
			case 54: 	type = Type.WINDOW;		material = Material.RED;		golden = true; 		break;
			
			case 55: 	type = Type.WINDOW;		material = Material.BLACK;		golden = false; 	break;
			case 56: 	type = Type.WINDOW;		material = Material.BLACK;		golden = false; 	break;
			case 57: 	type = Type.WINDOW;		material = Material.BLACK;		golden = false; 	break;
			case 58: 	type = Type.WINDOW;		material = Material.BLACK;		golden = false; 	break;
			case 59: 	type = Type.WINDOW;		material = Material.BLACK;		golden = true; 		break;
			
			case 60: 	type = Type.WINDOW;		material = Material.WHITE;		golden = false; 	break;
			case 61: 	type = Type.WINDOW;		material = Material.WHITE;		golden = false; 	break;
			case 62: 	type = Type.WINDOW;		material = Material.WHITE;		golden = false; 	break;
			case 63: 	type = Type.WINDOW;		material = Material.WHITE;		golden = false; 	break;
			case 64: 	type = Type.WINDOW;		material = Material.WHITE;		golden = true; 		break;
			
			
			
			// Roof elements
			case 65: 	type = Type.ROOF;		material = Material.BROWN;		golden = false; 	break;
			case 66: 	type = Type.ROOF;		material = Material.BROWN;		golden = false; 	break;
			case 67: 	type = Type.ROOF;		material = Material.BROWN;		golden = false; 	break;
			case 68: 	type = Type.ROOF;		material = Material.BROWN;		golden = false; 	break;
			
			case 69: 	type = Type.ROOF;		material = Material.GREEN;		golden = false; 	break;
			case 70: 	type = Type.ROOF;		material = Material.GREEN;		golden = false; 	break;
			case 71: 	type = Type.ROOF;		material = Material.GREEN;		golden = false; 	break;
			case 72: 	type = Type.ROOF;		material = Material.GREEN;		golden = false; 	break;
			
			case 73: 	type = Type.ROOF;		material = Material.RED;		golden = false; 	break;
			case 74: 	type = Type.ROOF;		material = Material.RED;		golden = false; 	break;
			case 75: 	type = Type.ROOF;		material = Material.RED;		golden = false; 	break;
			case 76: 	type = Type.ROOF;		material = Material.RED;		golden = false; 	break;
			
			case 77: 	type = Type.ROOF;		material = Material.BLACK;		golden = false; 	break;
			case 78: 	type = Type.ROOF;		material = Material.BLACK;		golden = false; 	break;
			case 79: 	type = Type.ROOF;		material = Material.BLACK;		golden = false; 	break;
			case 80: 	type = Type.ROOF;		material = Material.BLACK;		golden = false; 	break;
			
			case 81: 	type = Type.ROOF;		material = Material.WHITE;		golden = true; 		break;
			case 82: 	type = Type.ROOF;		material = Material.WHITE;		golden = true; 		break;
			case 83: 	type = Type.ROOF;		material = Material.WHITE;		golden = true; 		break;
			case 84: 	type = Type.ROOF;		material = Material.WHITE;		golden = true; 		break;
			
			
		}
	}
	
	
	public int getId() {
		return id;
	}
	
	
	public Type getType() {
		return type;
	}
	
	
	public Material getMaterial() {
		return material;
	}
	
	
	public boolean isGolden() {
		return golden;
	}
	
	
	public int getCost() {
		if(material == Material.BROWN) {
			return 3;
		} else if(material == Material.GREEN) {
			return 4;
		} else if(material == Material.RED) {
			return 5;
		} else if(material == Material.BLACK) {
			return 6;
		} else if(material == Material.WHITE) {
			return 8;
		}
		return 0;
	}
	
	
	/**
	 * Creates all tower elements for a tower element shop
	 */
	public static ArrayList<TowerElement> getElementPileForShop(Type shopType) {
		
		ArrayList<TowerElement> pile = new ArrayList<TowerElement>();
		TowerElement element;
		for(int i = 0; i < 85; i++) {
			element = new TowerElement(i);
			if(element.getType() == shopType) {
				pile.add(element);
			}
		}
		return pile;
	}


}
